#include <fstream>
#include <optional> // C++17 required

using namespace std;

std::optional<std::string> file_content(const char* path)
{
	std::ifstream file(path, std::ios::binary);
	if (!file.is_open())
		return std::nullopt;

	std::stringstream ss;
	ss << file.rdbuf();
	file.close();

	return std::optional<std::string>{std::move(ss.str())};
}

void test()
{
	auto buf =  file_content("E:\\OutputRGB.yu2v");
	if (!buf)
	{
		cout << "Fail to open file" << endl;
		return;
	}
	img.data = (uchar*)buf->c_str();
}
